package com.raycloud.java.dada.util;

import com.alibaba.fastjson.JSON;

/**
 * Created by hechuan on 2017/6/9.
 */
public class ObjecToJson {

    /**
     * 将对象序列化成json
     *
     * @param src
     * @param <T>
     * @return
     * @throws Exception
     */
    public static <T> String toJson(T src) throws Exception {
        if (src instanceof String) {
            return (String) src;
        } else {
            return JSON.toJSONString(src);
        }
    }
}
